home *** CD-ROM | disk | FTP | other *** search
/ SGI Desktop Special Edition 1.1 / SGI Desktop Special Edition 1.1.iso / dist / mmail.idb / usr / lib / Zmail / system.zmailrc.z / system.zmailrc
Encoding:
Text File  |  1995-11-13  |  13.5 KB  |  486 lines

  1. # system.zmailrc -- /usr/lib/Zmail/system.zmailrc init file for Z-Mail
  2. # Copyright (c) 1990-94 Z-Code Software, a Division of NCD.
  3.  
  4. # For easier system.zmailrc debugging, set the DBFILE environment
  5. # variable to the name of a file (or tty) that you wish to
  6. # receive debugging output, and use the -debug commandline option
  7. # when you start Z-Mail.
  8.  
  9. # When Z-Mail is run as a mail filter from the .forward file, the
  10. # environment is likely to be that of the MTA, not the user.  The
  11. # Z-Mail variable "home" is forced to be correct, so export it.
  12. setenv HOME $home
  13.  
  14. # Z-Mail and its users should always be able to execute Z-Mail utilities
  15. setenv PATH "${ZMLIB}/bin:${PATH}:/usr/local/bin:/usr/frame/bin"
  16.  
  17. # Set up the display early to allow quick exit in headers-only mode.
  18. # The hdrs_only flag is true if the command line was: "zmail -H".
  19. # The variable summary_fmt is set to change the format of the header
  20. # summaries that are displayed.
  21. if hdrs_only
  22.     set summary_fmt='%22a %M %-2N %T  %.31s'
  23. else
  24.     if is_lite
  25.     set summary_fmt='%22n %M %-2N %5T (%l) %s'
  26.     else
  27.     set summary_fmt='%22n %M %-2N %5T (%l) %.25s'
  28.     endif
  29. endif
  30.  
  31. # Interpret message priorities
  32. # Priority values 1 through 5 are reserved for compatibility with Z-Mail 2.1
  33. # and 3.0, which label those priorities with letters A through E.  "Urgent"
  34. # is recognized on received messages only, by default; X.400 MTAs send it.
  35. priority Urgent=6 High=7 Medium=8 Low=9
  36.  
  37. ##
  38. # If your mail transport agent uses lock files to synchronize with user
  39. # agents, you need to set dot_lock here.  This applies to most mailers
  40. # on System V Unix systems.
  41. ##
  42. # set dot_lock
  43. ##
  44. # The installation procedure should have correctly computed the value of
  45. # the "dot_lock" variable and created $ZMLIB/locking.zmailrc accordingly.
  46. # If you appear to be losing mail or to have trouble with NFS-mounted mail
  47. # delivery areas, check the above setting.
  48. ##
  49. if -e $ZMLIB/locking.zmailrc
  50.     source $ZMLIB/locking.zmailrc
  51. endif
  52.  
  53. ##########################################################################
  54. # Additional customizations for the local system should be added here.   #
  55. # Also check the rest of this file to be sure it is appropriate for your #
  56. # environment.                                                           #
  57. ##########################################################################
  58.  
  59. # The following is a convenient way to load local customizations.
  60. if -e $ZMLIB/custom.zmailrc
  61.     source $ZMLIB/custom.zmailrc
  62. endif
  63.  
  64. ## End local system customizations
  65.  
  66. ## Initialize local natural language support
  67. if $?LANG
  68.     if -e $ZMLIB/locale/$LANG/locale.zmailrc
  69.     source $ZMLIB/locale/$LANG/locale.zmailrc
  70.     else
  71.     source $ZMLIB/locale.zmailrc
  72.     endif
  73. else
  74.     source $ZMLIB/locale.zmailrc
  75. endif
  76.  
  77. ## Stop reading here if displaying headers is our only action
  78. if hdrs_only
  79.     return    # Quits reading this file
  80. endif
  81.  
  82. # This setting usually does no harm and stops problems before they show up.
  83. # Sun's sendmail.cf for diskless workstations is misconfigured to not allow
  84. # commas between addresses.
  85. set picky_mta += omit_commas
  86.  
  87. ## When reading messages, don't bother looking at lengthy, boring headers.
  88. ignore message-id received via status priority references
  89. ignore resent-message-id return-path return-receipt-to
  90. ignore mime-version content-type content-transfer-encoding
  91. ignore content-length content-lines content-identifier
  92. ignore encoding x-vue-version
  93. ignore x-face
  94.  
  95. # A few extra special-cases -- patterns like this are case-sensitive.
  96. ignore *Error* Content-* X400* Encoding*
  97.  
  98. # Set things up for the "Full headers" toggle in GUI modes
  99. # by ignoring headers that are part of $msg_win_hdr_fmt.
  100. # However, also retain these headers for hardcopy printing
  101. # (see $alwaysignore for more information).
  102. if is_gui
  103.     retain From Date Subject Name Reply-To Resent-[FDTC]* To Cc
  104.     ignore From From* Date Subject Name To Cc    # From* hits "From " line
  105.     set display_headers = unignored
  106. endif
  107. if is_lite
  108.     retain From Date Name Subject Reply-To Resent-[FDTC]* To Cc
  109.     ignore From From* Date Subject Name        # From* hits "From " line
  110.     set display_headers = unignored
  111. endif
  112.  
  113. # Set the print_cmd to mailp by default.
  114. if ! $?print_cmd
  115.   set print_cmd = "$ZMLIB/bin/mailp -W80 %O"
  116.   setenv MP_PROLOGUE "$ZMLIB/mp"
  117. endif
  118.  
  119. # By default, zmail's history is set to the last command only.  Set it to
  120. # remember the last 100 commands.
  121. set history = 100
  122.  
  123. # If the variable "unix" is set, then any command that isn't a zmail command
  124. # will execute the command as if you typed it from the shell.  Note, such
  125. # commands will not go through another shell -- this is it.  This may be
  126. # considered confusing for new users, so it is commented out by default.
  127. set unix
  128.  
  129. # Label replies with a header showing the who, what, and when of the
  130. # message being replied-to.
  131. set in_reply_to='%f\n\t"%s" (%d)'
  132.  
  133. # Mail routing and address-fixing conveniences.  If auto_route is set, then
  134. # replies to messages take a closer look at the addresses of the recipients.
  135. # If any redundant paths are present, they are pruned.  Also, the path that
  136. # precedes any hosts listed in the "known_hosts" list is truncated.  This is
  137. # useful for uucp sites only, and is therefore commented out by default.
  138. # set auto_route known_hosts="sun ucbcad well unicom"
  139.  
  140. function resend() {
  141. #% (fallback help text)
  142. #     resend [msg-list] [addresses]
  143. #
  144. # Resend (unedited) the listed messages to the addresses.
  145. #%
  146.     # Versions earlier than 2.1 do not support "mail -resend".
  147.     # Use equivalent backwards-compatible options just in case.
  148.     mail -send -forward $*
  149. }
  150. #   # Below is the Z-Script implementation.  The prompting originally
  151. #   # supported by function resend is now a builtin to "mail -resend".
  152. #
  153. #   shift -m            # Skip the messages specifed or selected.
  154. #   if $status < 0        # If the message list had an error, return.
  155. #    return
  156. #   endif
  157. #   set _msgs = "$output"    # Set _msgs to be result of "shift -m".
  158. #   if "X$_msgs" != X        # If there were messages,
  159. #    msg_list - $_msgs    # Set current message correctly.
  160. #   endif
  161. #   if $argc == 1        # If no other args exist, prompt for user list.
  162. #    ask -i userid "Forward to:"
  163. #    if $status == -1    # If user cancelled command, return now.
  164. #    return
  165. #    endif
  166. #   else
  167. #    set userid = "$*"    # Addresses already specified, get from args.
  168. #   endif
  169. #   mail -resend $_msgs $userid    # Forward messages to userid(s).
  170. #   msg_list $_msgs | unset userid _msgs    # Set $output and unset locals.
  171.  
  172. function saveit() {
  173. #% (fallback help text)
  174. #      saveit [msg-list]
  175. #%
  176.     if "x$_save_file" == "x"
  177.         eval ask -f __save_file -d +/. "$__ask_saving"
  178.     else
  179.         ask -f __save_file -d "$__save_file" "$__ask_saving"
  180.     endif
  181.     if $status == 0
  182.     save $* "$__save_file"
  183.     endif
  184. }
  185.  
  186. function bugreport() {
  187. #% (fallback help text)
  188. # Use this function to send mail to report problems with Z-Mail.
  189. #%
  190.     mail -p bugs        # mail using prepared bugreport form
  191. }
  192. # button -n Gripe bugreport
  193.  
  194. function view_msg() {
  195. #% (fallback help text)
  196. #      view_msg [folder]
  197. #
  198. # This is used to view a single rfc822 message in a file
  199. #%
  200.  
  201.     if $# == 1
  202.     open -T "$1"
  203.     if $status == 0
  204.         pinup ^
  205.     else
  206.         return $status
  207.     endif
  208.     else
  209.     eval error "$__err_takes_one_arg"
  210.     endif
  211.     return 0
  212. }
  213.  
  214. function view_fldr() {
  215. #% (fallback help text)
  216. #      view_fldr [folder]
  217. #
  218. # This is used to view a folder (file of more than one message)
  219. #%
  220.     if $# != 1
  221.     eval error "$__err_takes_one_arg"
  222.     return 0 # Suppress attachment error dialog
  223.     endif
  224.     if $?main_state:(folder_writable)
  225.     ask -m -i __how -d "$__choice_merge" "$__ask_show_folder" \
  226.         "$__choice_create" "$__choice_temp"
  227.     if $status != 0
  228.         return 0
  229.     endif
  230.     else
  231.     ask -m -i __how -d "$__choice_temp" "$__ask_show_folder" \
  232.         "$__choice_create"
  233.     if $status != 0
  234.         return 0
  235.     endif
  236.     endif
  237.     unset __list
  238.     if "$__how" == "$__choice_merge"
  239.     merge "$1" | set __list
  240.     if $status != 0
  241.         return 0
  242.     endif
  243.     else
  244.     open -T "$1" | set __list
  245.     if $status != 0
  246.         return 0
  247.     endif
  248.     if ! $?__list
  249.         close -n "$1"
  250.         return 0
  251.     endif
  252.     if "$__how" == "$__choice_create"
  253.         ask -f __vf_folder "$__ask_folder_write"
  254.         if $status == 0
  255.         copy * $__vf_folder
  256.         unset __list
  257.         open $__vf_folder | set __list
  258.         set __status == $status
  259.         close -n "$1"
  260.         if $__status != 0
  261.             return 0
  262.         endif
  263.         else
  264.         close -n "$1"
  265.         endif
  266.     endif
  267.     ask -l __list -d 1 "$__ask_show_message" $__list 
  268.     if $status == 0
  269.         pinup $__list
  270.     endif
  271.     endif
  272.     return 0
  273. }
  274.  
  275. function page_edit() {
  276. #% (fallback help text)
  277. #      page_edit [filename]
  278. #
  279. # This is used to create a new text file
  280. #%
  281.     sh touch $1
  282.     page -e $1
  283. }
  284.  
  285.  
  286. function window_sh() {
  287. #% (fallback help text)
  288. #      window_sh command args ...
  289. #
  290. # Run an external command, in its own window if appropriate.  Note that
  291. # this forces use of a terminal emulator, even if $window_shell is empty.
  292. #%
  293.     # Use of "$1" "$2" etc. works around unavailability of "$@" for now.
  294.     if is_lite
  295.     builtin screencmd -p builtin sh "$1" "$2" "$3" "$4" "$5" "$6" "$7" \
  296.         "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$16" "$17" \
  297.         "$18" "$19" "$20" "$21" "$22" "$23" "$24" "$25"
  298.     return $status
  299.     endif
  300.     if is_gui
  301.     if $?window_shell
  302.         set __window_shell = "$window_shell"
  303.     else
  304.         set __window_shell
  305.     endif
  306.     if X"$__window_shell" == X
  307.         set __winterm
  308.         if $?winterm
  309.         if X"$winterm" != X
  310.             set __winterm = "$winterm"
  311.         endif
  312.         endif
  313.         if X"$__winterm" != X
  314.         set __window_shell = "$__winterm -e"
  315.         else
  316.         set __window_shell = "xterm -e"
  317.         endif
  318.     endif
  319.     builtin sh $__window_shell "$1" "$2" "$3" "$4" "$5" "$6" "$7" \
  320.         "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$16" "$17" \
  321.         "$18" "$19" "$20" "$21" "$22" "$23" "$24" "$25"
  322.     return $status
  323.     endif
  324.     builtin sh "$1" "$2" "$3" "$4" "$5" "$6" "$7" \
  325.     "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15" "$16" "$17" \
  326.     "$18" "$19" "$20" "$21" "$22" "$23" "$24" "$25"
  327.     return $status
  328. }
  329.  
  330. # This function may used for adding new types automatically.
  331. # Currently, defining this is a security hole in that arbitrary text
  332. # can be executed as Z-Mail commands, with possible bad consequences.
  333. #
  334. # attach -type NewType ":addtype '%s'" None "Commands to create a new type"
  335. #
  336. # function addtype() {
  337. #     # This should be improved to allow ONLY "attach" commands
  338. #     echo "Adding new attachment type ..."
  339. #     source $1
  340. #     sh rm $1
  341. #     attach
  342. # }
  343.  
  344. # Do some tricks with X resources ...
  345. #if is_lite
  346. #    exit    # Exit this script, not the program
  347. #endif
  348. #if is_gui
  349. #    if ! $?XAPPLRESDIR
  350. #    if ! -e /usr/lib/X11/app-defaults/Zmail
  351. #        setenv XAPPLRESDIR $ZMLIB
  352. #    else
  353. #        setenv XAPPLRESDIR /usr/lib/X11/app-defaults
  354. #    endif
  355. #   endif
  356. #   if $?XUSERFILESEARCHPATH
  357. #    if "$XUSERFILESEARCHPATH" !~ "*:$XAPPLRESDIR*"
  358. #        setenv XUSERFILESEARCHPATH "$XAPPLRESDIR/%N:$XUSERFILESEARCHPATH"
  359. #    endif
  360. #   endif
  361. #endif
  362.  
  363. function zmfilter_reply_each () {
  364. #% (fallback help text)
  365. #      zmfilter_reply_each [filename]
  366. #
  367. # This is used to reply to a message using a template file.  The string
  368. # $SUBJECT in the template file is replaced with the message's subject.
  369. #%
  370.     setenv SUBJECT "$[%s]"
  371.     sh "sed 's/"'\$SUBJECT'"/'"'"$SUBJECT"/'" $1 > /tmp/reply$$"
  372.     unsetenv SUBJECT
  373.     if $?autoinclude
  374.         set __need_autoinclude
  375.         unset autoinclude
  376.     endif
  377.     reply -unedited -draft /tmp/reply$$
  378.     if $?__need_autoinclude
  379.         set autoinclude
  380.         unset __need_autoinclude
  381.     endif
  382. }
  383.  
  384. function zmfilter_reply() {
  385.     foreach m $input 'msg_list - $m ; zmfilter_reply_each $1'
  386. }
  387.  
  388. function create_aiff () {
  389. #% (fallback help text)
  390. #      create_aiff [recordaiff arguments]
  391. #
  392. # This function is used to create new audio attachments by recording
  393. # from the microphone.
  394. #%
  395.     sh -m 'Activating microphone' apanel -nodisplay -nofork -source mic
  396.     sh -m 'Recording ... press <Stop> when done.' recordaiff $*
  397.  
  398.     if $?child
  399.     sh kill -INT $child
  400.     endif
  401. }
  402.  
  403. function view_external () {
  404. #% (fallback help text)
  405. #      view_external filename access-type [name [site [direcory [mode [server]]]]]
  406. #
  407. # Display an external-body part.  If the part is external because the
  408. # recipient chose to remove it, present a special-case error message.
  409. #%
  410.     if !$?METAMAIL_PAGER
  411.     if $?PAGER
  412.         if "$PAGER" == more
  413.         setenv METAMAIL_PAGER 'more -w'
  414.         else
  415.         setenv METAMAIL_PAGER "$PAGER"
  416.         endif
  417.     else
  418.         setenv METAMAIL_PAGER 'more -w'
  419.     endif
  420.     endif
  421.         
  422.     if "$2" == "x-removed-by-recipient"
  423.     error "$__err_part_removed"
  424.     return 0
  425.     else
  426.         window_sh "$zmlib/bin/showexternal" "$1" "$2" "$3" "$4" "$5" "$6" "$7"
  427.     return $status
  428.     endif
  429. }
  430.  
  431. function trustable_address() {
  432.     if "$1" !~ "*|*"
  433.     if "$1" !~ "*[     <,][+/~]*"
  434.         return 0
  435.     endif
  436.     endif
  437.     builtin eval builtin error "$__err_suspect_address"
  438. }
  439.  
  440. function trusted_mailto () {
  441. #% (fallback help text)
  442. #    trusted_mailto [ address [ subject [ body [ inperson-reply ] ] ] ]
  443. #%
  444.     builtin mail
  445.     trustable_address "$1"
  446.     if !$status
  447.     builtin compcmd to "$1"
  448.     endif
  449.     builtin compcmd subject "$2"
  450.     if "x$3" != "x"
  451.     builtin compcmd append-text "$3"
  452.     endif
  453.     if "x$4" != "x"
  454.     trustable_address "$4"
  455.     if !$status
  456.         builtin compcmd insert-header X-InPerson-Address: "$4"
  457.     endif
  458.     endif
  459. }
  460.  
  461. function trusted_sendfile () {
  462. #% (fallback help text)
  463. #    trusted_sendfile filename [ address [ subject [ body ] ] ]
  464. #%
  465.     trusted_mailto "$2" "$3" "$4"
  466.     builtin compcmd attach-file "$1"
  467. }
  468.  
  469.  
  470.  
  471. # pick up menu and button definitions
  472. source $ZMLIB/zmail.menus
  473. source $ZMLIB/sgi.func
  474.  
  475. # "cmd" is used to set command line aliases similar to the way "csh"
  476. # does it.  The only difference is that "alias" is a reserved word in
  477. # Z-Mail and Mail, so cmd is used.
  478. #
  479. cmd dq 'd \!*; q'        # Delete a message list, then quit.
  480. cmd unread 'flags \!* U O'    # Mark messages unread.
  481.  
  482. # pick up Lite system initialization
  483. if is_lite
  484.     source $ZMLIB/system.literc
  485. endif
  486.